package com.bah.tract.client.ui;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.table.TableModel;

import com.bah.tract.client.ui.TaskComboModel.TaskLabel;
import com.bah.tract.service.Task;

public class TaskPropertiesMouseAdapter extends MouseAdapter {

	private final TOLPropertiesDialog mTolPropertiesDialog;

	private final TaskTable mTaskTable;

	TaskPropertiesMouseAdapter(final TOLPropertiesDialog tolPropertiesDialog,
			final TaskTable taskTable) {
		mTolPropertiesDialog = tolPropertiesDialog;
		mTaskTable = taskTable;
	}

	@Override
	public final void mouseClicked(final MouseEvent e) {
		if (e.getClickCount() == 2) {
			final TableModel model = mTaskTable.getModel();
			final TaskLabel taskLabel = (TaskLabel) model.getValueAt(
					mTaskTable.getSelectedRow(), 2);
			final Task task = taskLabel.getTask();
			if ("ChargeNumber".equals(task.getType())) {
				mTolPropertiesDialog.setVisible(true);
				mTolPropertiesDialog.setTask(task);
			}
		}
	}
}
